<!DOCTYPE html>
<html lang="en">
    <head>
		<meta charset="UTF-8">
		<title>修改密码</title>
		<link rel="stylesheet" href="__ADMIN_PATH__/component/pear/css/pear.css" />
	</head>
	<body>
		<form class="layui-form" action="">
			<div class="mainBox">
				<div class="main-container">

					<div class="layui-form-item">
						<label class="layui-form-label"><font color="red">*</font>原始密码</label>
						<div class="layui-input-block">
							<input type="password" name="oldpassword" autocomplete="off" placeholder="请输入原始密码" class="layui-input">
						</div>
					</div>

					<div class="layui-form-item">
						<label class="layui-form-label"><font color="red">*</font>新密码</label>
						<div class="layui-input-block">
							<input type="password" name="newpassword" autocomplete="off" placeholder="请输入新密码" class="layui-input">
						</div>
					</div>

					<div class="layui-form-item">
						<label class="layui-form-label"><font color="red">*</font>确认密码</label>
						<div class="layui-input-block">
							<input type="password" name="respassword" autocomplete="off" placeholder="请输入确认密码" class="layui-input">
						</div>
					</div>

				</div>
			</div>
			<div class="bottom">
				<div class="button-container">
					<button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
						lay-filter="edit_password">
						<i class="layui-icon layui-icon-ok"></i>
						提交
					</button>
					<button type="reset" class="pear-btn pear-btn-sm">
						<i class="layui-icon layui-icon-refresh"></i>
						重置
					</button>
				</div>
			</div>
		</form>
		<script src="__ADMIN_PATH__/component/layui/layui.js"></script>
		<script src="__ADMIN_PATH__/component/pear/pear.js"></script>
		<script>
			layui.use(['form', 'jquery', 'popup', 'loading'], function() {
				let form = layui.form;
				let $ = layui.jquery;
				var popup = layui.popup;
				let loading = layui.loading;
				/**
				 * 提交表单
				 */
				form.on('submit(edit_password)', function(data) {
					$.ajax({
						url:"{:url('Publics/edit_password')}",
						type:"POST",
						dataType:"JSON",
						data:data.field,
						beforeSend: function () {
							loading.Load(1, "");
		                },
		                complete: function () {
		                	loading.loadRemove();
		                },
		                success:function(res)
		                {
		                	if(res.code == 0)
		                	{
		                		//正常业务
		                		popup.success(res.msg, function(){
		                			var index = parent.layer.getFrameIndex(window.name);
		                			parent.location.reload();
		                			parent.layer.close(index); //再执行关闭
	                        	});
		                	}else if(res.code == -400)
		                	{
		                		//登录失效
		                		popup.warming(res.msg, function(){
		                			var index = parent.layer.getFrameIndex(window.name);
		                			parent.location.reload();
		                			parent.layer.close(index); //再执行关闭
		                		});
		                	}else
		                	{
		                		//业务异常
		                		popup.warning(res.msg);
		                	}
		                },
		                error:function()
		                {
		                	loading.loadRemove();
		                	popup.failure('服务器错误');
		                }
		            });
		            return false;
		        });
			});
		</script>
	</body>
</html>